VERSION 5.00
Begin VB.Form frmShell 
   BackColor       =   &H00FFFFFF&
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "X-Bot Shell Maintenance"
   ClientHeight    =   4305
   ClientLeft      =   45
   ClientTop       =   315
   ClientWidth     =   7770
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4305
   ScaleWidth      =   7770
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox txtTelnetPort 
      Height          =   285
      IMEMode         =   3  'DISABLE
      Left            =   1560
      MaxLength       =   5
      TabIndex        =   27
      Text            =   "22"
      ToolTipText     =   $"frmShell.frx":0000
      Top             =   1200
      Width           =   855
   End
   Begin VB.Frame Frame1 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Telnet or SSH?"
      ForeColor       =   &H80000008&
      Height          =   855
      Left            =   840
      TabIndex        =   25
      Top             =   3240
      Visible         =   0   'False
      Width           =   1335
      Begin VB.OptionButton optSSH 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "SSH"
         ForeColor       =   &H80000008&
         Height          =   255
         Left            =   120
         TabIndex        =   4
         Top             =   480
         Value           =   -1  'True
         Width           =   1575
      End
   End
   Begin VB.CommandButton butExecute 
      Caption         =   "Step 3: Execute this Bot on the Shell"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      Style           =   1  'Graphical
      TabIndex        =   10
      Top             =   3360
      Width           =   3975
   End
   Begin VB.CommandButton butUploadScript 
      Caption         =   "Upload Bot's Custom TCL Scripts"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1920
      Style           =   1  'Graphical
      TabIndex        =   11
      Top             =   3840
      Width           =   3975
   End
   Begin VB.Timer Timer1 
      Interval        =   100
      Left            =   7080
      Top             =   0
   End
   Begin VB.CommandButton butSettings 
      Caption         =   "Save Settings"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4320
      Style           =   1  'Graphical
      TabIndex        =   12
      Top             =   2400
      Width           =   1575
   End
   Begin VB.CommandButton butRemServer 
      Caption         =   "-"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   5760
      Style           =   1  'Graphical
      TabIndex        =   15
      Top             =   360
      Width           =   375
   End
   Begin VB.CommandButton butAddServer 
      Caption         =   "+"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   5280
      Style           =   1  'Graphical
      TabIndex        =   14
      Top             =   360
      Width           =   375
   End
   Begin VB.ComboBox txtServer 
      Height          =   315
      Left            =   1560
      TabIndex        =   1
      ToolTipText     =   "What is the server on which you have a shell?  Usually in the format: shell.domain.net"
      Top             =   360
      Width           =   3615
   End
   Begin VB.TextBox txtPath 
      Height          =   285
      Left            =   2520
      TabIndex        =   7
      Text            =   "/usr/home/YOUR_USERNAME/x-bot"
      ToolTipText     =   "Do not change this unless you know what this means."
      Top             =   1920
      Width           =   3375
   End
   Begin VB.CommandButton butInstallXBot 
      Caption         =   "Step 1: Install X-Bot to Shell"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      Style           =   1  'Graphical
      TabIndex        =   8
      Top             =   2400
      Width           =   3975
   End
   Begin VB.TextBox txtFtpPort 
      Height          =   285
      IMEMode         =   3  'DISABLE
      Left            =   4800
      TabIndex        =   5
      Text            =   "5999"
      ToolTipText     =   $"frmShell.frx":00A3
      Top             =   1200
      Width           =   1335
   End
   Begin VB.CommandButton butDelete 
      Caption         =   "Delete This Bot from Shell"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   4320
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   3120
      Width           =   1575
   End
   Begin VB.CommandButton butUpload 
      Caption         =   "Step 2: Upload Compiled Bot"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      Style           =   1  'Graphical
      TabIndex        =   9
      Top             =   2880
      Width           =   3975
   End
   Begin VB.TextBox txtPassword 
      Height          =   285
      IMEMode         =   3  'DISABLE
      Left            =   4800
      PasswordChar    =   "*"
      TabIndex        =   3
      Text            =   "gatorade"
      ToolTipText     =   "What is the password needed to gain access to the account with the username you typed in."
      Top             =   720
      Width           =   1335
   End
   Begin VB.TextBox txtUser 
      Height          =   285
      Left            =   1560
      TabIndex        =   2
      Text            =   "ot-ftp"
      ToolTipText     =   "What is your Login/Username for this account?"
      Top             =   720
      Width           =   1335
   End
   Begin VB.CheckBox chkPassive 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Use Passive Mode for FTP"
      Height          =   375
      Left            =   6360
      TabIndex        =   6
      ToolTipText     =   "Check this if you are having a rough time uploading or are behind a firewall."
      Top             =   1120
      Width           =   1455
   End
   Begin VB.Line Line2 
      X1              =   0
      X2              =   7800
      Y1              =   1080
      Y2              =   1080
   End
   Begin VB.Label Label4 
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "SSH Port:"
      Height          =   255
      Left            =   120
      TabIndex        =   28
      Top             =   1200
      Width           =   1335
   End
   Begin VB.Label lblDir 
      Alignment       =   2  'Center
      BackColor       =   &H00C0C0FF&
      Caption         =   "You must install to a directory in your home directory named x-bot (lowercase)."
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   1035
      Left            =   6000
      TabIndex        =   26
      Top             =   1800
      Width           =   1800
   End
   Begin VB.Shape Shape5 
      BackColor       =   &H00000000&
      BackStyle       =   1  'Opaque
      Height          =   855
      Left            =   120
      Top             =   2760
      Width           =   3975
   End
   Begin VB.Label Label7 
      BackStyle       =   0  'Transparent
      Caption         =   "(*) = Required on most servers.  Leave blank if unknown"
      Height          =   855
      Left            =   6360
      TabIndex        =   24
      Top             =   275
      Width           =   1335
   End
   Begin VB.Label lstBots 
      BackColor       =   &H00808080&
      Caption         =   "Loading..."
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000FFFF&
      Height          =   255
      Left            =   2520
      TabIndex        =   23
      Top             =   0
      Width           =   3975
   End
   Begin VB.Label Label6 
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "Full Path to X-Bot on the shell:"
      Height          =   255
      Left            =   240
      TabIndex        =   22
      Top             =   1920
      Width           =   2175
   End
   Begin VB.Label Label5 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H00808080&
      Caption         =   "If ports are left empty, default ports for those protocols will be used"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   195
      Left            =   0
      TabIndex        =   21
      Top             =   1560
      Width           =   7770
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "FTP Port:"
      Height          =   255
      Left            =   3360
      TabIndex        =   20
      Top             =   1200
      Width           =   1335
   End
   Begin VB.Label lblBotName 
      Alignment       =   1  'Right Justify
      Appearance      =   0  'Flat
      BackColor       =   &H00808080&
      Caption         =   "Currently working with bot:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   195
      Left            =   -360
      TabIndex        =   19
      Top             =   0
      Width           =   2730
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      BackColor       =   &H0080FFFF&
      Caption         =   $"frmShell.frx":0143
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   1395
      Left            =   6000
      TabIndex        =   18
      Top             =   2880
      Width           =   1800
   End
   Begin VB.Line Line3 
      X1              =   120
      X2              =   5880
      Y1              =   2280
      Y2              =   2280
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "Shell Password (*):"
      Height          =   255
      Left            =   3360
      TabIndex        =   17
      Top             =   720
      Width           =   1335
   End
   Begin VB.Label lblUser 
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "Shell Username (*):"
      Height          =   255
      Left            =   -120
      TabIndex        =   16
      Top             =   720
      Width           =   1575
   End
   Begin VB.Label lblServer 
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "Shell Server (*):"
      Height          =   255
      Left            =   240
      TabIndex        =   0
      Top             =   360
      Width           =   1215
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00808080&
      BackStyle       =   1  'Opaque
      BorderStyle     =   0  'Transparent
      Height          =   275
      Left            =   -240
      Top             =   0
      Width           =   8055
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00808080&
      BackStyle       =   1  'Opaque
      Height          =   255
      Left            =   0
      Top             =   1560
      Width           =   7815
   End
   Begin VB.Shape Shape3 
      BackColor       =   &H00C0FFFF&
      BackStyle       =   1  'Opaque
      BorderStyle     =   0  'Transparent
      Height          =   1095
      Left            =   0
      Top             =   0
      Width           =   7815
   End
   Begin VB.Shape Shape4 
      BackColor       =   &H0080FFFF&
      BackStyle       =   1  'Opaque
      BorderColor     =   &H0000FFFF&
      BorderStyle     =   0  'Transparent
      Height          =   2655
      Left            =   6000
      Top             =   1800
      Width           =   1815
   End
End
Attribute VB_Name = "frmShell"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim itraHeader As String

Private Sub butAddServer_Click()
txtServer.Text = ""
txtServer_Change
End Sub

Private Sub butDelete_Click()
butDelete.Enabled = False
SaveShells
txtServer_Change

Open App.Path & "\upload.txt" For Output As #1 'ftp script
    Print #1, "hash"
    Print #1, "open " & txtServer.Text & " " & txtFtpPort.Text
    Print #1, txtUser.Text
    Print #1, txtPassword.Text      ' in ~
    Print #1, "cd x-bot"            ' in x-bot
    Print #1, "delete " & lstBots & ".conf"
    Print #1, "delete " & lstBots & ".user"
    Print #1, "delete " & lstBots & ".chan"
    Print #1, "delete " & lstBots & ".notes"
    Print #1, "cd scripts"            ' in scripts
    Print #1, "delete " & lstBots & ".bs.3.0.conf"
    Print #1, "quit"
Close #1

Open App.Path & "\upload.bat" For Output As #1 'used to execute ftp
    Print #1, "@echo off"
    Print #1, "title Deleting Bot - " & lstBots & "..."
    Print #1, "ftp -s:" & App.Path & "\upload.txt" 'execute FTP Script
    Print #1, "del " & App.Path & "\upload.txt" 'leave no traces of the script and its contents
    Print #1, "echo _________________________________________"
    Print #1, "echo This bot is now deleted from this shell account"
    Print #1, "echo - You may now click the 'x' in the upper right corner of this window"
    Print #1, "pause"
Close #1

Shell App.Path & "\upload.bat", vbMaximizedFocus 'execute batch file
DoEvents

butDelete.Enabled = True
End Sub

Private Sub butExecute_Click()
butExecute.Enabled = False
SaveShells
txtServer_Change

''Reset_itraHeader
Dim Protocol As String
Dim FrontLine As String 'stores data at front of every line in the batch file

'If optTelnet.Value = True Then
'    Protocol = "telnet"
'Else
    Protocol = "ssh"
'End If

FrontLine = "plink -" & Protocol & " " & txtServer.Text & " -batch -P " & txtTelnetPort.Text & " -l " & txtUser.Text & " -pw " & txtPassword.Text & " "

'start telnet.bat by adding this server into putty's record to avoid it bitching at me
Open App.Path & "\telnet.bat" For Output As #1
    Print #1, "@echo off"
    Print #1, "Title Configuring X-Bot on Shell... Please Stand by..."
    Print #1, Left(App.Path, 1) & ":"
    Print #1, "chdir " & App.Path
    Print #1, "plink -" & Protocol & " " & txtServer.Text & " -P " & txtTelnetPort.Text & " -l " & txtUser.Text & " -pw " & txtPassword.Text & " -m commands.txt"
    Print #1, "y"
Close #1

' make server settings
Open App.Path & "\commands.txt" For Output As #1
''itraHeader = itraHeader & txtServer.Text & ":" & txtTelnetPort.Text & "/My X-Bot Shell" & vbCrLf

' now each command goes on its own line
''itraHeader = itraHeader & txtUser.Text & vbCrLf     ' user
''itraHeader = itraHeader & txtPassword.Text & vbCrLf ' pass

Dim OutFile As String
''itraHeader = itraHeader & "cd x-bot" & vbCrLf          ' in x-bot
OutFile = "cd x-bot" & Chr(10)
' make appropriate path adjustments
''itraHeader = itraHeader & "cat " & lstBots & ".conf | sed sed '1s|^.*$|" & frmShell.txtPath.Text & "|' >xbshell.tmp && mv xbshell.tmp " & lstBots & ".conf"
OutFile = OutFile & "cat " & lstBots & ".conf | sed sed '1s|^.*$|" & frmShell.txtPath.Text & "|' >xbshell.tmp && mv xbshell.tmp " & lstBots & ".conf" & Chr(10)
''itraHeader = itraHeader & "eggdrop -m " & lstBots & ".conf" & vbCrLf

'backup userfiles
OutFile = OutFile & "cp Main.user.backup Main.user.backup.2" & Chr(10)
OutFile = OutFile & "cp Main.user Main.user.backup" & Chr(10)

OutFile = OutFile & "cp " & lstBots & ".user.backup " & lstBots & ".user.backup.2" & Chr(10)
OutFile = OutFile & "cp " & lstBots & ".user " & lstBots & ".user.backup" & Chr(10)

'remove old pid file if somehow it still exists
OutFile = OutFile & ".rm pid." & lstBots & Chr(10)
OutFile = OutFile & "./eggdrop -m " & lstBots & ".conf" & Chr(10)
''itraHeader = itraHeader & "quit"
OutFile = OutFile & "quit" & Chr(10)

' write file
''Open App.Path & "\ImagicaTelnet\itra.dat" For Output As #1
''    Print #1, itraHeader
''Close #1
Print #1, OutFile
Close #1

Open App.Path & "\telnet.bat" For Append As #1
Print #1, "title Done."
Print #1, "echo _________________________________________"
Print #1, "echo Bot Executing Now..."
Print #1, "echo - PLEASE FOLLOW THE ON SCREEN INSTRUCTIONS IF THIS IS THE FIRST TIME YOU ARE USING THIS BOT ON THE SHELL"
Print #1, "echo - You may now close this window by clicking the 'x' in the top-right corner of this window"
Print #1, "pause"
Close #1

' Telnet script will be activated by execution of the program
''Shell App.Path & "\ImagicaTelnet\ImagicaTelnet.exe show", vbNormalFocus


Shell Chr(34) & App.Path & "\telnet.bat" & Chr(34), vbMaximizedFocus 'execute batch file
DoEvents

butExecute.Enabled = True
End Sub

Private Sub butInstallXBot_Click()
butInstallXBot.Enabled = False
SaveShells
txtServer_Change

''Reset_itraHeader

Dim Protocol As String
Dim FrontLine As String 'stores data at front of every line in the batch file
Dim OutFile As String

'If optTelnet.Value = True Then
'    Protocol = "telnet"
'Else
    Protocol = "ssh"
'End If

FrontLine = "plink -" & Protocol & " " & txtServer.Text & " -batch -P " & txtTelnetPort.Text & " -l " & txtUser.Text & " -pw " & txtPassword.Text & " "

'start telnet.bat by adding this server into putty's record to avoid it bitching at me
Open App.Path & "\telnet.bat" For Output As #1
    Print #1, "@echo off"
    Print #1, "Title Configuring X-Bot on Shell... Please Stand by..."
    Print #1, "plink -" & Protocol & " " & txtServer.Text & " -P " & txtTelnetPort.Text & " -l " & txtUser.Text & " -pw " & txtPassword.Text & " -m commands.txt"
    Print #1, "y"
Close #1



' make server settings
'' = removed with putty addition
''itraHeader = itraHeader & txtServer.Text & ":" & txtTelnetPort.Text & "/My X-Bot Shell" & vbCrLf

' now each command goes on its own line
''itraHeader = itraHeader & txtUser.Text & vbCrLf     ' user
''itraHeader = itraHeader & txtPassword.Text & vbCrLf ' pass

' commands from: Phil
''itraHeader = itraHeader & "cd x-bot" & vbCrLf       ' in x-bot
OutFile = OutFile & "cd x-bot" & Chr(10)
''itraHeader = itraHeader & "mkdir tmp" & vbCrLf
OutFile = OutFile & "mkdir tmp" & Chr(10)
''itraHeader = itraHeader & "gunzip eggdrop.tar.gz" & vbCrLf
'OutFile = OutFile & "gunzip -dv eggdrop.tar.gz" & Chr(10)  'not needed
''itraHeader = itraHeader & "tar -zxvf eggdrop.tar" & vbCrLf
OutFile = OutFile & "tar -zxf eggdrop.tar.gz" & Chr(10)
' end of commands from: Phil

''itraHeader = itraHeader & "cd .." & vbCrLf          ' in ~
OutFile = OutFile & "cd .." & Chr(10)
''itraHeader = itraHeader & "mv x-bot/scripts x-bot/scripts2/" & vbCrLf    ' need to move scripts before can overwrite
OutFile = OutFile & "mv x-bot/scripts x-bot/scripts2/" & Chr(10)
''itraHeader = itraHeader & "mv x-bot/eggdrop1.6.12/* x-bot/" & vbCrLf     ' move things in eggdrop directory to x-bot directory
OutFile = OutFile & "mv x-bot/eggdrop1.6.13/* x-bot/" & Chr(10)
''itraHeader = itraHeader & "mv x-bot/scripts2/* x-bot/scripts/" & vbCrLf  ' move the old scripts back to scripts directory
OutFile = OutFile & "mv x-bot/scripts2/* x-bot/scripts/" & Chr(10)

' clean up empty directories
''itraHeader = itraHeader & "rm -rf x-bot/eggdrop1.6.12/" & vbCrLf
'OutFile = OutFile & "rm -rf x-bot/eggdrop1.6.13/" & Chr(10)
''itraHeader = itraHeader & "rm -rf x-bot/scripts2/" & vbCrLf
OutFile = OutFile & "rm -rf x-bot/scripts2/" & Chr(10)

' Sept 15, 2002
' eggdrop is now in x-Bot directory
' DOH - Must compile Eggdrop - forgot this in build 55

' should be in ~ but just make sure
''itraHeader = itraHeader & "cd ~" & vbCrLf
'OutFile = OutFile & "cd ~"
''itraHeader = itraHeader & "cd x-bot" & vbCrLf   ' now in x-bot
OutFile = OutFile & "cd x-bot" & Chr(10)

''itraHeader = itraHeader & "./configure" & vbCrLf
OutFile = OutFile & "./configure" & Chr(10)
''itraHeader = itraHeader & "make config" & vbCrLf
OutFile = OutFile & "make config" & Chr(10)
''itraHeader = itraHeader & "make" & vbCrLf
OutFile = OutFile & "make" & Chr(10)
''itraHeader = itraHeader & "make install DEST=" & txtPath.Text
OutFile = OutFile & "make install" & Chr(10) ' DEST=" & txtPath.Text & Chr(10)

OutFile = OutFile & "mkdir modules" & Chr(10)
OutFile = OutFile & "mv *.so modules" & Chr(10)

OutFile = OutFile & "exit"
' write file
''Open App.Path & "\ImagicaTelnet\itra.dat" For Output As #1
    ''Print #1, itraHeader
''Close #1
Open App.Path & "\commands.txt" For Output As #1
    Print #1, OutFile
Close #1

' Telnet script will be activated by execution of the program
' ============================================================
' FTP
' ===

Open App.Path & "\upload.txt" For Output As #1 'ftp script
    Print #1, "hash"
    Print #1, "verbose"
    Print #1, "open " & txtServer.Text & " " & txtFtpPort.Text
    Print #1, txtUser.Text
    Print #1, txtPassword.Text      ' in ~
    
    
    ' time to upload x-bot specific files
    Dim BSolutions(92) As String 'array of files specific to the /bsolutions directory
    BSolutions(1) = "access.3.0.tcl"
    BSolutions(2) = "act.3.0.tcl"
    BSolutions(3) = "addchan.3.0.tcl"
    BSolutions(4) = "admin.3.0.tcl"
    BSolutions(5) = "auth.3.0.tcl"
    BSolutions(6) = "ban.3.0.tcl"
    BSolutions(7) = "banlist.3.0.tcl"
    BSolutions(8) = "broadcast.3.0.tcl"
    BSolutions(9) = "chanstats.3.0.tcl"
    BSolutions(10) = "chkaccess.3.0.tcl"
    BSolutions(11) = "commands.3.0.tcl"
    BSolutions(12) = "comment.3.0.tcl"
    BSolutions(13) = "core.3.0.tcl"
    BSolutions(14) = "credits.3.0.tcl"
    BSolutions(15) = "cycle.2.2.tcl"
    BSolutions(16) = "deauth.3.0.tcl"
    BSolutions(17) = "deop.3.0.tcl"
    BSolutions(18) = "deoped.3.0.tcl"
    BSolutions(19) = "devoice.3.0.tcl"
    BSolutions(20) = "disable.3.0.tcl"
    BSolutions(21) = "enable.3.0.tcl"
    BSolutions(22) = "globauth.3.0.tcl"
    BSolutions(23) = "help.3.0.tcl"
    BSolutions(24) = "invite.3.0.tcl"
    BSolutions(25) = "kernal.3.0.tcl"
    BSolutions(26) = "kick.3.0.tcl"
    BSolutions(27) = "kickwarn.3.0.tcl"
    BSolutions(28) = "killmodes.3.0.tcl"
    BSolutions(29) = "logout.3.0.tcl"
    BSolutions(30) = "m.access.3.0.tcl"
    BSolutions(31) = "m.act.3.0.tcl"
    BSolutions(32) = "m.addchan.3.0.tcl"
    BSolutions(33) = "m.admin.3.0.tcl"
    BSolutions(34) = "m.ban.3.0.tcl"
    BSolutions(35) = "m.banlist.3.0.tcl"
    BSolutions(36) = "m.broadcast.3.0.tcl"
    BSolutions(37) = "m.chanstats.3.0.tcl"
    BSolutions(38) = "m.commands.3.0.tcl"
    BSolutions(39) = "m.comment.3.0.tcl"
    BSolutions(40) = "m.core.3.0.tcl"
    BSolutions(41) = "m.credits.3.0.tcl"
    BSolutions(42) = "m.cycle.2.2.tcl"
    BSolutions(43) = "m.deop.3.0.tcl"
    BSolutions(44) = "m.devoice.3.0.tcl"
    BSolutions(45) = "m.disable.3.0.tcl"
    BSolutions(46) = "m.enable.3.0.tcl"
    BSolutions(47) = "m.help.3.0.tcl"
    BSolutions(48) = "m.invite.3.0.tcl"
    BSolutions(49) = "m.kick.3.0.tcl"
    BSolutions(50) = "m.killmodes.3.0.tcl"
    BSolutions(51) = "m.mode.3.0.tcl"
    BSolutions(52) = "m.op.3.0.tcl"
    BSolutions(53) = "m.rehash.3.0.tcl"
    BSolutions(54) = "m.remchan.3.0.tcl"
    BSolutions(55) = "m.restart.3.0.tcl"
    BSolutions(56) = "m.save.3.0.tcl"
    BSolutions(57) = "m.say.3.0.tcl"
    BSolutions(58) = "m.servers.3.0.tcl"
    BSolutions(59) = "m.sndmsg.3.0.tcl"
    BSolutions(60) = "m.sndnote.3.0.tcl"
    BSolutions(61) = "m.sndnotice.3.0.tcl"
    BSolutions(62) = "m.topic.3.0.tcl"
    BSolutions(63) = "m.unban.3.0.tcl"
    BSolutions(64) = "m.useradd.3.0.tcl"
    BSolutions(65) = "m.userdel.3.0.tcl"
    BSolutions(66) = "m.userlist.3.0.tcl"
    BSolutions(67) = "m.usermod.3.0.tcl"
    BSolutions(68) = "m.version.3.0.tcl"
    BSolutions(69) = "m.voice.3.0.tcl"
    BSolutions(70) = "mode.3.0.tcl"
    BSolutions(71) = "mscomicwarn.3.0.tcl"
    BSolutions(72) = "onjoin.3.0.tcl"
    BSolutions(73) = "op.3.0.tcl"
    BSolutions(74) = "rehash.3.0.tcl"
    BSolutions(75) = "remchan.3.0.tcl"
    BSolutions(76) = "restart.3.0.tcl"
    BSolutions(77) = "save.3.0.tcl"
    BSolutions(78) = "say.3.0.tcl"
    BSolutions(79) = "servers.3.0.tcl"
    BSolutions(80) = "sndmsg.3.0.tcl"
    BSolutions(81) = "sndnote.3.0.tcl"
    BSolutions(82) = "sndnotice.3.0.tcl"
    BSolutions(83) = "topic.3.0.tcl"
    BSolutions(84) = "unban.3.0.tcl"
    BSolutions(85) = "useradd.3.0.tcl"
    BSolutions(86) = "userdel.3.0.tcl"
    BSolutions(87) = "userlist.3.0.tcl"
    BSolutions(88) = "usermod.3.0.tcl"
    BSolutions(89) = "version.3.0.tcl"
    BSolutions(90) = "voice.3.0.tcl"
    BSolutions(91) = "m.onjoin.3.0.tcl"
    BSolutions(92) = "chanmodes.3.0.tcl"
    
    Dim Scripts(5) As String
    Scripts(1) = "bot-solutions.3.0.tcl"
    Scripts(2) = "action.fix.tcl"
    Scripts(3) = "winident1.2.tcl"
    Scripts(4) = "alltools.tcl"
    Scripts(5) = "compat.tcl"
    
    Dim Counter As Integer
    
    
    Print #1, "ascii"
    Print #1, "mkdir x-bot"
    Print #1, "cd x-bot"            ' in x-bot
    
    
    Print #1, "mkdir scripts"
    Print #1, "cd scripts"         'back to x-bot/scripts

    For Counter = 1 To 5
        Print #1, "put"
        Print #1, Chr(34) & App.Path & "\windrop\scripts\" & Scripts(Counter) & Chr(34)
        Print #1, Scripts(Counter)
    Next Counter
    
    Print #1, "cd .."               'back to x-bot/
    Print #1, "mkdir bsolutions"
    Print #1, "cd bsolutions"       ' in x-bot/bsolutions
    
    For Counter = 1 To 92
        Print #1, "put"
        Print #1, Chr(34) & App.Path & "\windrop\bsolutions\" & BSolutions(Counter) & Chr(34)
        Print #1, BSolutions(Counter)
    Next Counter
    
    Print #1, "bye"
    Print #1, "!"
Close #1
Open App.Path & "\upload2.txt" For Output As #1
    'Print #1, "cd .."           'back to x-bot
    Print #1, "verbose"
    Print #1, "hash"
    Print #1, "open " & txtServer.Text & " " & txtFtpPort.Text
    Print #1, txtUser.Text
    Print #1, txtPassword.Text      ' in ~
    
    Print #1, "trace"
    Print #1, "cd x-bot"
    Print #1, "delete eggdrop.tar.gz" 'scrap old file if partially uploaded
    Print #1, "binary"
    Print #1, "put"
    Print #1, Chr(34) & App.Path & "\eggdrop.tar.gz" & Chr(34)
    Print #1, "eggdrop.tar.gz"
    Print #1, "bye"
    Print #1, "!"
Close #1

Open App.Path & "\upload.bat" For Output As #1 'used to execute ftp
    Print #1, "@echo off"
    Print #1, "title Uploading X-Bot - Scripts... ( # = 2 Kilobytes Uploaded)"
    'MsgBox "skipping ftp #1"
    Print #1, "ftp -s:" & Chr(34) & App.Path & "\upload.txt" & Chr(34) 'execute FTP Script
    Print #1, "title Uploading X-Bot - Core... ( # = 2 Kilobytes Uploaded)"
    'MsgBox "Skipping ftp #2"
    Print #1, "ftp -s:" & Chr(34) & App.Path & "\upload2.txt" & Chr(34) 'execute FTP Script
    Print #1, "del " & Chr(34) & App.Path & "\upload.txt" & Chr(34) 'leave no traces of the script and its contents
    Print #1, "del " & Chr(34) & App.Path & "\upload2.txt" & Chr(34) 'leave no traces of the script and its contents
    Print #1, "title Installing X-Bot to Shell..."
    Print #1, "cls"
    Print #1, "Title Configuring X-Bot..."
    Print #1, Left(App.Path, 1) & ":"
    Print #1, "chdir " & App.Path
    'MsgBox "skipping telnet"
    Print #1, "call telnet.bat"
    Print #1, "del " & Chr(34) & App.Path & "\telnet.bat" & Chr(34)
    Print #1, "echo _________________________________________"
    Print #1, "title Finished uploading this X-Bot" 'close command window
    Print #1, "echo Finished uploading this X-Bot..."
    Print #1, "echo - You may now close this window by clicking the 'X' in the upper right-hand corner."
    Print #1, "pause"
Close #1

Shell Chr(34) & App.Path & "\upload.bat" & Chr(34), vbMaximizedFocus 'execute batch file
DoEvents
butInstallXBot.Enabled = True
Me.SetFocus
End Sub
Sub Reset_itraHeader()
'itraHeader = "~ML!"
'Exit Sub

itraHeader = "~CUSER!Default.dat" & vbCrLf & _
    "~MLIDX! 0" & vbCrLf & _
    "~TOP! 1845" & vbCrLf & _
    "~LEFT! 1545" & vbCrLf & _
    "~WIDTH! 8085" & vbCrLf & _
    "~HEIGHT! 7545" & vbCrLf & _
    "~STIP! 1" & vbCrLf & _
    "~BMCL! 0" & vbCrLf & _
    "~BCCL! 0" & vbCrLf & _
    "~TMCL! 16777215" & vbCrLf & _
    "~TCCL! 16777215" & vbCrLf & _
    "~COMMW! 0" & vbCrLf & _
    "~SOUND! 1" & vbCrLf & _
    "~ML!"

End Sub

Private Sub butRemServer_Click()
On Error Resume Next

Dim Response As Integer
Response = MsgBox("Are you sure you wish to delete your settings for " & txtServer.Text & " ?", vbQuestion + vbYesNoCancel, App.ProductName)

If Response = vbYes Then 'save changes reflecting removal of this server
    ProfileDeleteSection txtServer.Text, App.Path & "\shells.ini"
    txtServer.RemoveItem txtServer.ListIndex
    txtServer.ListIndex = 0
    SaveShells
End If
End Sub

Private Sub butSettings_Click()
SaveShells
txtServer_Change
End Sub

Private Sub butUpload_Click()
butUpload.Enabled = False
SaveShells
txtServer_Change

'files to upload
' /windrop/<name>.conf
' /windrop/scripts/<name>.bs.3.0.conf


' TELNET:
'   cat infile | sed sed '1s|^.*$|your line|' >tmpfile && mv tmpfile infile
'   ... replaces first line of file with text
'
Open App.Path & "\upload.txt " For Output As #1 'ftp script"
    Print #1, "hash"
    Print #1, "verbose"
    Print #1, "open " & txtServer.Text & " " & txtFtpPort.Text
    Print #1, txtUser.Text
    Print #1, txtPassword.Text      ' in ~
       
    Print #1, "ascii"
    Print #1, "cd x-bot"            ' in x-bot
    Print #1, "delete " & lstBots & ".conf"
    Print #1, "send"
    Print #1, App.Path & "\windrop\" & lstBots & ".conf"
    Print #1, lstBots & ".conf"

    Print #1, "cd scripts"          ' in x-bot/scripts
    Print #1, "delete " & lstBots & ".bs.3.0.conf"
    Print #1, "send"
    Print #1, App.Path & "\windrop\scripts\" & lstBots & ".bs.3.0.conf"
    Print #1, LCase(lstBots) & ".bs.3.0.conf"
    Print #1, "bye"
    Print #1, "!"
Close #1

Open App.Path & "\upload.bat" For Output As #1 'used to execute ftp
    Print #1, "@echo off"
    Print #1, "title Uploading Bot - " & lstBots & "... ( # = 2 Kilobytes Uploaded)"
    Print #1, "ftp -s:" & App.Path & "\upload.txt" 'execute FTP Script
    Print #1, "del " & App.Path & "\upload.txt" 'leave no traces of the script and its contents
    
    Print #1, "echo _________________________________________"
    Print #1, "echo Your bot has been successfully uploaded to this shell account"
    Print #1, "echo - You may now click the 'x' in the upper right corner of this window"
    Print #1, "pause"

Close #1

Shell App.Path & "\upload.bat", vbMaximizedFocus 'execute batch file
DoEvents

butUpload.Enabled = True
End Sub



Private Sub butUploadScript_Click()
' see if there are any scripts to upload first
Dim Counter As Integer

If Window.lstScripts.ListCount <= 3 Then
    MsgBox "Sorry, there are no custom scripts that need to be uploaded for this bot at this time.", vbInformation, App.ProductName
    Exit Sub
Else
    ' upload the scripts
    butUploadScript.Enabled = False
    SaveShells
    
    Open App.Path & "\upload.txt " For Output As #1 'ftp script"
        Print #1, "hash"
        Print #1, "verbose"
        Print #1, "open " & txtServer.Text & " " & txtFtpPort.Text
        Print #1, txtUser.Text
        Print #1, txtPassword.Text      ' in ~
        
        Print #1, "ascii"
        Print #1, "cd x-bot"
        Print #1, "cd scripts"
        
        ' all scripts are in windrop\scripts
        For Counter = 0 To Window.lstScripts.ListCount - 1
            Window.lstScripts.ListIndex = Counter
            
            ' exclude certain scripts
            If LCase(Window.lstScripts) = "bot-solutions.3.0.tcl" Or _
                LCase(Window.lstScripts) = "alltools.tcl" Or _
                LCase(Window.lstScripts) = "compat.tcl" Then
                    ' do not upload
            Else
                Print #1, "delete " & Window.lstScripts
                Print #1, "send"
                Print #1, Chr(34) & App.Path & "\windrop\scripts\" & Window.lstScripts & Chr(34)
                Print #1, Window.lstScripts
            End If
        Next Counter
        
        Print #1, "bye"
        Print #1, "!"
    Close #1
    
    Open App.Path & "\upload.bat" For Output As #1 'used to execute ftp
        Print #1, "@echo off"
        Print #1, "title Uploading Bot - " & lstBots & "... ( # = 2 Kilobytes Uploaded)"
        Print #1, "ftp -s:" & App.Path & "\upload.txt" 'execute FTP Script
        Print #1, "del " & App.Path & "\upload.txt" 'leave no traces of the script and its contents
        
        
        Print #1, "echo _________________________________________"
        Print #1, "echo This bot's custom scripts are now all uploaded"
        Print #1, "echo - You may now click the 'x' in the upper right corner of this window"
        Print #1, "pause"
    Close #1
    
    Shell App.Path & "\upload.bat", vbMaximizedFocus 'execute batch file
    DoEvents
    
    butUploadScript.Enabled = True
End If
End Sub

Private Sub Form_Load()
' Load Images
Me.Icon = Window.Icon

butAddServer.Picture = xsplash.button.Picture
butRemServer.Picture = xsplash.button.Picture
butInstallXBot.Picture = xsplash.button.Picture
butSettings.Picture = xsplash.button.Picture
butDelete.Picture = xsplash.button.Picture
butUpload.Picture = xsplash.button.Picture
butUploadScript.Picture = xsplash.button.Picture
butExecute.Picture = xsplash.button.Picture

' Load shell settings
Dim Counter As Long
Dim TotalShells As Integer
TotalShells = CInt(ProfileGetItem("servers", "total", "0", App.Path & "\shells.ini"))

For Counter = 1 To TotalShells
    txtServer.AddItem ProfileGetItem("servers", CStr(Counter), "Unnamed Server " & Counter, App.Path & "\shells.ini")
Next Counter

On Error Resume Next
txtServer.ListIndex = 0
txtServer_Change

DoEvents
' copy Window.lstProfiles to lstBots

lstBots.Clear

Dim OldIndex As Long

' remember current listindex in window
OldIndex = Window.lstProfile.ListIndex

For Counter = 0 To Window.lstProfile.ListCount - 1
    Window.lstProfile.ListIndex = Counter
    lstBots.AddItem Window.lstProfile
Next Counter

' return to old listindex
Window.lstProfile.ListIndex = OldIndex
GentleOpen Me
DoEvents

'' if only 1 bot, automatically highlight it
'If lstBots.ListCount = 1 Then
'    lstBots.ListIndex = 0
'    lstBots_Click
'    DoEvents
'End If


End Sub


Private Sub Form_Unload(Cancel As Integer)
GentleClose Me
End Sub

Private Sub optSSH_Click()
If txtTelnetPort.Text = "23" Then txtTelnetPort.Text = ""
End Sub

Private Sub optTelnet_Click()
If txtTelnetPort.Text = "22" Then txtTelnetPort.Text = ""
End Sub

Private Sub Timer1_Timer()
lstBots.Caption = Window.lstProfile
End Sub

Private Sub txtPath_Change()

If Right(txtPath.Text, Len("/x-bot")) <> "/x-bot" And Me.Visible Then
    lblDir.Visible = True
Else
    lblDir.Visible = False
End If
End Sub

Private Sub txtServer_Change()
Dim Rijndael As Object
Set Rijndael = New clsRijndael

If Trim(txtServer.Text) = "" Then
    txtUser.Text = ""
    txtPassword.Text = ""
    txtTelnetPort.Text = ""
    txtFtpPort.Text = ""
    txtPath.Text = "/usr/home/YourUsername/X-Bot"
    chkPassive.Value = 0
Else
    txtUser.Text = ProfileGetItem(txtServer.Text, "user", "", App.Path & "\shells.ini")
    
    'rijndael cannot decrypt a null string
    If ProfileGetItem(txtServer.Text, "password", "", App.Path & "\shells.ini") <> "" Then
        txtPassword.Text = Rijndael.DecryptString(ProfileGetItem(txtServer.Text, "password", "", App.Path & "\shells.ini"), txtUser.Text)
    End If
    
    txtTelnetPort.Text = ProfileGetItem(txtServer.Text, "telnet", "", App.Path & "\shells.ini")
    txtFtpPort.Text = ProfileGetItem(txtServer.Text, "ftp", "", App.Path & "\shells.ini")
    txtPath.Text = ProfileGetItem(txtServer.Text, "path", "", App.Path & "\shells.ini")
    chkPassive.Value = ProfileGetItem(txtServer.Text, "passive", "0", App.Path & "\shells.ini")
    
    Dim TempStr As String
    TempStr = ProfileGetItem(txtServer.Text, "ssh", "false", App.Path & "\shells.ini")
    
'    If TempStr = False Then
'        optTelnet.Value = True
'    Else
        optSSH.Value = True
'    End If
End If

End Sub

Sub SaveShells()
On Error Resume Next

' parse default path to correct path
txtPath.Text = Parse(txtPath.Text, "YOUR_USERNAME", txtUser.Text)

' update ports
'If optTelnet.Value = True Then
'    If txtTelnetPort.Text = "" Then txtTelnetPort.Text = "23"
'Else
    If txtTelnetPort.Text = "" Then txtTelnetPort.Text = "22"
'End If
If txtFtpPort.Text = "" Then txtFtpPort.Text = "21"

Dim Rijndael As Object
Set Rijndael = New clsRijndael

ProfileSaveItem txtServer.Text, "user", txtUser.Text, App.Path & "\shells.ini"

If txtPassword.Text <> "" Then
    ProfileSaveItem txtServer.Text, "password", Rijndael.EncryptString(txtPassword.Text, txtUser.Text), App.Path & "\shells.ini"
End If

ProfileSaveItem txtServer.Text, "telnet", txtTelnetPort.Text, App.Path & "\shells.ini"
ProfileSaveItem txtServer.Text, "ftp", txtFtpPort.Text, App.Path & "\shells.ini"
ProfileSaveItem txtServer.Text, "path", txtPath.Text, App.Path & "\shells.ini"
ProfileSaveItem txtServer.Text, "passive", chkPassive.Value, App.Path & "\shells.ini"

If optSSH.Value = True Then
    ProfileSaveItem txtServer.Text, "ssh", "true", App.Path & "\shells.ini"
Else
    ProfileSaveItem txtServer.Text, "ssh", "false", App.Path & "\shells.ini"
End If

Dim CurrentIndex As Integer
Dim Counter As Integer
Dim CurrentServer As String
Dim InList As Boolean

' see if current text is in the server list, if not, add it
CurrentServer = txtServer.Text
CurrentIndex = txtServer.ListIndex

For Counter = 0 To txtServer.ListCount - 1
    txtServer.ListIndex = Counter
    
    If txtServer.Text = CurrentServer Then InList = True
Next Counter
If InList = False Then
    txtServer.AddItem CurrentServer
End If

' update servers list
ProfileSaveItem "servers", "total", CStr(txtServer.ListCount), App.Path & "\shells.ini"

For Counter = 0 To txtServer.ListCount - 1
    txtServer.ListIndex = Counter
    ProfileSaveItem "servers", CStr(Counter + 1), txtServer.Text, App.Path & "\shells.ini"
Next Counter

txtServer.ListIndex = CurrentIndex
End Sub

Private Sub txtServer_Click()
txtServer_Change
End Sub

Private Sub txtUser_Change()

' automatically guess path to X-Bot on shell if not already entered
'If Trim(txtXPath.Text) = "" Then
'    txtXPath.Text = "/home/" & txtUser.Text & "/xbot/"
'End If

End Sub

